package concurrentAPI;

public class NanotimeExample {
	
	public static void main(String[] args) throws InterruptedException {
		long startTime = System.nanoTime();
		
		Thread.sleep(500);
		
		long endTime = System.nanoTime();
	
		long runningTime = endTime - startTime;

		System.out.println("Start time: " + startTime);
		System.out.println("End time: " + endTime);
		System.out.println("Running time: " + runningTime);	 
	}

	public static void main1(String[] args) {
		long startTimeMillis = System.currentTimeMillis();
	    long startTimeNanos = System.nanoTime();

	    long currentTimeMillis;
	    while((currentTimeMillis = System.currentTimeMillis()) == startTimeMillis) {
	    }
	    // 1 000 000 nanos = 1 milli
	    System.out.println(System.nanoTime()-startTimeNanos);
	    System.out.println(currentTimeMillis-startTimeMillis);
	}
}
